<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="lib/vue.js"></script>
</head>
<body>
<div id="root">
<!--    <input @input="getName" v-model="firstName" type="text" placeholder="请输入姓氏">+-->
<!--    <input @input="getName" v-model="lastName" type="text" placeholder="请输入名称">-->


<!--    <input  v-model="firstName" type="text" placeholder="请输入姓氏">+-->
<!--    <input  v-model="lastName" type="text" placeholder="请输入名称">-->

    <input  v-model="firstName" type="text" placeholder="请输入姓氏">+
    <input  v-model="lastName" type="text" placeholder="请输入名称">
    <p>全名--->  {{name}}</p>
</div>
</body>
<script>
    new Vue({
        el : '#root',
        data:{
            name:'',
            firstName :'',
            lastName :''
        },
        watch:{
            firstName(newValue){
                this.name = newValue + this.lastName;
            },
            lastName(newValue){
                this.name = this.firstName + newValue;
            }
        }
        // computed:{
        //     name(){
        //         return this.firstName + this.lastName;
        //     }
        // }
        // methods:{
        //     getName(){
        //         this.name = this.firstName + this.lastName;
        //     }
        // }
    })
</script>
</html>